﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Marin.Entities;
using Marin.Service;

namespace Marin.UI
{
    public partial class frmDetNewEgreso : Form
    {
        private IDetNewSer NewDetService;
        public frmDetNewEgreso()
        {
            InitializeComponent();
            NewDetService= new DetalleNewService();
        }

        private string Motivo = "";
        private decimal PrecioUnt = 0;
        string Descripcion = "";
        
        private DateTime? fecha = null;
        private void btnAdd_Click(object sender, EventArgs e)
        {
           
            Motivo = txtMotivo.Text;
              PrecioUnt = decimal.Parse(txtPrecio.Text);
              Descripcion = txtDescripcion.Text;
            fecha = ddpFecha.Value;
            
            
                 
           
                //detalleNewEgresoBindingSource.DataSource = Motivo;
                detalleNewEgresoDataGridView.Rows.Add(Descripcion,Motivo,PrecioUnt,fecha);
                Sum();
            
        }
        private void Sum()
        {
            totalLabel1.Text = Convert.ToString(detalleNewEgresoDataGridView.Rows.Cast<DataGridViewRow>().Sum(x => Convert.ToDecimal(x.Cells["precioU"].Value)));
        }

        private void btnGuardar_Click(object sender, EventArgs e)
        {
            var current = detalleNewEgresoDataGridView.CurrentCell;
            try
            {
                foreach (DataGridViewRow row in detalleNewEgresoDataGridView.Rows)
                {
                    
                }
            }
            catch (Exception)
            {
                
                throw;
            }
        }
    }
}
